/*
 *
A(int)
A(const A&)
98

 */

#include <iostream>
using namespace std;
class A{
	public:
		int m_data;
		A(int data = 0){
			cout << "A(int)" << endl;
			m_data = data;
		}
#if 1
		A(const A& that){  //拷贝构造函数
			cout << "A(const A&)" << endl;
			m_data = that.m_data;
		}
#endif 
};
class B{
	public:
		A m_a;
};
int main(void){
#if 0
	A a1(123);
	A a2(a1); //编译器会调用拷贝构造函数
	A a3 = a1; //调用拷贝构造
	cout << a2.m_data <<endl;
	cout << a3.m_data <<endl;
#endif
	B b1; //调用A的构造函数
	b1.m_a.m_data = 98;
	B b2 = b1; //调用B的缺省拷贝构造函数，由于有成员对象m_a, 所以会调用A的拷贝构造函数
	cout << b2.m_a.m_data << endl;
	return 0;
}

